package com.zhentao.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import lombok.Data;

/**
 * 原始表映射表：存储异常数据的原始表关联关系，用于溯源
 * @TableName source_table_mapping
 */
@TableName(value ="source_table_mapping")
@Data
public class   SourceTableMapping implements Serializable {
    /**
     * 映射ID
     */
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * 关联采集主表ID
     */
    private Integer collectionId;

    /**
     * 原始表名称
     */
    private String sourceTableName;

    /**
     * 原始数据快照
     */
    private String sourceData;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        SourceTableMapping other = (SourceTableMapping) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getCollectionId() == null ? other.getCollectionId() == null : this.getCollectionId().equals(other.getCollectionId()))
            && (this.getSourceTableName() == null ? other.getSourceTableName() == null : this.getSourceTableName().equals(other.getSourceTableName()))
            && (this.getSourceData() == null ? other.getSourceData() == null : this.getSourceData().equals(other.getSourceData()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getCollectionId() == null) ? 0 : getCollectionId().hashCode());
        result = prime * result + ((getSourceTableName() == null) ? 0 : getSourceTableName().hashCode());
        result = prime * result + ((getSourceData() == null) ? 0 : getSourceData().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", collectionId=").append(collectionId);
        sb.append(", sourceTableName=").append(sourceTableName);
        sb.append(", sourceData=").append(sourceData);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}